package com.hadoop.project.mvc.controller;

import com.hadoop.project.entity.po.VideoRank;
import com.hadoop.project.entity.query.VideoRankQuery;
import com.hadoop.project.entity.vo.ResponseVO;
import com.hadoop.project.mvc.service.VideoRankService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: Controller
 * @author:alexmaodali
 * @date:2025/4/13
 */
@RestController
@RequestMapping("/videoRank")
@ApiOperation(value = "标签排名接口")
public class VideoRankController extends ABaseController {

	@Resource
	private VideoRankService videoRankService;

	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("loadDataList")
	public ResponseVO loadDataList(VideoRankQuery query) {
		return getSuccessResponseVO(videoRankService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("add")
	public ResponseVO add(VideoRank bean) {
		this.videoRankService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<VideoRank> listBean) {
		System.out.println("listBean = " + listBean);
		this.videoRankService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增或修改
	 */
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<VideoRank> listBean) {
		this.videoRankService.addOrUpdateBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询
	 */
	@RequestMapping("getVideoRankById")
	public ResponseVO  getVideoRankById(Long id) {
		return getSuccessResponseVO(this.videoRankService.getVideoRankById(id));
	}

	/**
	 * 根据Id更新
	 */
	@RequestMapping("updateVideoRankById")
	public ResponseVO updateVideoRankById(VideoRank bean,Long id) {
		this.videoRankService.updateVideoRankById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("deleteVideoRankById")
	public ResponseVO deleteVideoRankById(Long id) {
		this.videoRankService.deleteVideoRankById(id);
		return getSuccessResponseVO(null);
	}


}
